<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>确认订单</title>
    <link rel="stylesheet" type="text/css" href="../../css/index.css" />
    <style>
        .warp{width: 100%;}
        input::-webkit-input-placeholder{color: #BDBDBD;font-size: 14px;}
    	input::-moz-placeholder{color: #BBBBBB;font-size: 14px;}

        /*地址信息*/
        .addr-info{width: 100%;height:100px;align-items: center;background:#ffffff;margin-bottom: 10px;padding: 10px 0;box-sizing: border-box;}
		.addr-info .icon{width: 20px;height: 20px;margin: 0 15px;flex-shrink: 0;}
		.addr-info .goto{width: 13px;height: 13px;margin: 0 15px;flex-shrink: 0;}
        .addr-info .top .phone{padding-left: 10px;}
		.addr-info .addr-box{color: #333333;}
		.addr-info .addr-box .top{font-size: 16px;}
        .addr-info .addr-box .top .name{margin-right: 10px;}
		.addr-info .addr-box .content{padding-top: 4px;box-sizing: border-box;font-size: 14px;word-break: break-all;color: #999999}
		.addr-info .no-addr{line-height: 80px;color: #333333;}

		/*商品信息*/
		.order-conter{width: 100%;}
		.order-conter .order-shop{padding: 20px 15px;box-sizing: border-box;background: #FFFFFF;}
		.order-conter .order-shop .img-box{width: 92px;height: 92px;overflow:hidden;}
		.order-conter .order-shop .img-box img{width: 100%;display:block;}
		.order-conter .order-shop .shop-info{padding-left: 12px;box-sizing: border-box;position: relative;flex-direction: column;}
		.order-conter .order-shop .shop-info .name{font-size: 14px;color: #333333;}
		.order-conter .order-shop .shop-info .guige-box{color:#8E9194;font-size: 12px;padding-top: 14px;box-sizing: border-box;line-height: 18px;}
        .order-conter .order-shop .shop-info .guige-box .guige{padding-right: 20px;box-sizing: border-box;}
        .order-conter .order-shop .shop-info .guige-box .num{color: #333333}
		.order-conter .order-shop .shop-info .price{width: 100%;align-items: center;padding-top: 6px;box-sizing: border-box;}
		.order-conter .order-shop .shop-info .price .p1{font-size: 18px;margin-top: 1px;color: #FF9502;font-weight:bold;box-sizing: border-box;line-height: 20px;}
		.order-conter .order-shop .shop-info .price .p3{font-size: 18px;color: #FF9502;margin-top: 1px;font-weight:bold;line-height: 20px;}
        .order-conter .order-shop .shop-info .price .p3 .t{font-size: 16px;line-height: 20px;}
        .order-conter .order-shop:last-child::before{display: none;}

        /*订单价格信息*/
		.price-info{width: 100%;background: #FFFFFF;margin-bottom: 10px;}
		.price-info .info-one{align-items: center;height: 50px;padding: 0 15px;box-sizing: border-box;}
		.price-info .info-one .l{font-size: 14px;color: #333333;}
		.price-info .info-one .r{font-size: 14px;color: #333333;text-align: right;padding-left: 10px;box-sizing: border-box;}

		/*优惠券*/
		.youhui-box{align-items: center;background: #FFFFFF;height: 50px;padding-left:15px;box-sizing: border-box;margin-bottom: 10px;}
		.youhui-box .l{font-size: 14px;color: #333333;}
		.youhui-box .r{font-size: 14px;color: #333333;text-align: right;padding-left: 10px;box-sizing: border-box;}
    	.youhui-box .goto{width: 13px;height: 13px;margin: 3px 15px 0 4px;flex-shrink: 0;}

    	/*留言*/
    	.liuyan-box{width: 100%;background: #FFFFFF;margin-bottom: 10px;height: 50px;padding: 0 15px;align-items: center;box-sizing: border-box;}
    	.liuyan-box .title{font-size: 14px;color: #333333;box-sizing: border-box;padding-right: 10px;box-sizing: border-box;flex-shrink: 0}
    	.liuyan-box input{height: 50px;text-align: right;}

    	/*底部按钮*/
    	.bot-btn{position: fixed;width: 100%;background: #FFFFFF;padding-left:15px;box-sizing: border-box;bottom: 0;left: 0;z-index: 10;}
    	.bot-btn .price{font-size: 12px;}
    	.bot-btn .price span{font-size: 20px;font-weight:bold;color: #FF9502}
    	.bot-btn .btn{width: 120px;height: 50px;background: #FF9502;text-align: center;line-height:50px;font-size: 16px;color: #FFFFFF;}

    </style>
</head>

<body>
    <div id="vue" class="warp">

    	<!--地址-->
		<div class="addr-info flex" tapmode onclick="open_address(this);">
			<img class="icon" src="../../image/main3/addr_icon.png"/>
			<div class="addr-box flex1" v-if="Pdata.address">
				<div class="top"><span class="name" v-text="Pdata.address.uname"></span><span class="phone" v-text="Pdata.address.phone"></span></div>
				<div class="content" v-text="Pdata.address.qustr + Pdata.address.address"></div>
			</div>
			<div class="no-addr flex1" v-if="Pdata.address == null">请添加收货地址</div>
			<img class="goto" src="../../image/main0/show_goto.png"/>
		</div>

        <!--品牌商品列表-->
        <div class="order-warp" v-for="(item,key) in Pdata.orderData">
    		<div class="order-conter">
    			<div class="order-shop flex border-bottom" v-for="(i,k) in item.goods">
    				<div class="img-box">
    					<img :src="i.image"/>
    				</div>
    				<div class="shop-info flex1 flex">
    					<div class="name han_1" v-text="i.title"></div>
    					<div class="guige-box flex flex1">
    						<div class="guige flex1 han_1" v-if="i.ggstr" v-text="i.ggstr"></div>
                            <div class="guige flex1 han_1" v-if="i.ggstr == null"></div>
    						<div class="num" v-text="'x'+i.buynum"></div>
    					</div>
    					<div class="price flex" v-if="i.goodstype == 0 || i.goodstype == 1">
    						<div class="p1" v-text="'¥'+i.price"></div>
    						<div class="p3" v-if="i.unscore">+<i v-text="i.unscore"></i><i class="t">积分</i></div>
    					</div>
                        <div class="price flex" v-if="i.goodstype == 2">
    						<div class="p1" v-if="i.pricetype == 'rmb' || i.pricetype == 'scoreandrmb'" v-text="'¥'+i.price"></div>
    						<div class="p3" v-if="i.pricetype == 'score' || i.pricetype == 'scoreandrmb'"><i v-if="i.pricetype == 'scoreandrmb'">+</i><i v-text="i.unscore"></i><i class="t">积分</i></div>
    					</div>
    				</div>
    			</div>
    		</div>
            <!--运费-->
            <div class="price-info border-top" style="margin-bottom:0;">
    			<div class="info-one flex">
    				<div class="l">
                        运费
                        <!-- <i v-if="item.orderman">(满<i v-text="item.orderman"></i>元包邮)</i> -->
                    </div>
    				<!-- <div class="r flex1" v-if="item.unYunfeiSta == 0">+¥<i v-text="item.orderYunfei"></i></div> -->
                    <!-- <div class="r flex1" v-if="item.unYunfeiSta == 1">包邮</div> -->
                    <div class="r flex1" v-text="'¥'+item.fenzuYunfei"></div>
    			</div>
    		</div>
            <!--留言-->
    		<div class="liuyan-box flex border-top">
    			<div class="title">买家留言</div>
    			<input class="beizhu flex1" maxlength="100" :data-id="item.fenzuId" oninput="inputMiaoShu(this)" placeholder="建议留言前先与商家沟通确认"></input>
    		</div>
        </div>

		<!--优惠券-->
		<div class="youhui-box flex" tapmode onclick="open_quan(this);" v-if="shoptype != 'jifen'">
			<div class="l">优惠券</div>
			<div class="r flex1">
                <div v-if="Pdata.orderQuanData.type == 'money'">已抵扣<i v-text="Pdata.orderQuanData.unprice"></i>元</div>
                <div v-if="Pdata.orderQuanData.type == 'mshui'">已使用免税券</div>
                <div v-if="Pdata.orderQuanData.type == 'baoyou'">已使用包邮券</div>
            </div>
			<img class="goto" src="../../image/main0/show_goto.png"/>
		</div>

		<!--价格信息-->
		<div class="price-info">
			<div class="info-one flex border-bottom">
				<div class="l">商品金额</div>
				<div class="r flex1">¥<i v-text="Pdata.orderGoodsPrice"></i></div>
			</div>
			<div class="info-one flex border-bottom" v-if="shoptype != 'jifen'">
				<div class="l">优惠券</div>
				<div class="r flex1">-¥<i v-text="Pdata.orderQuanUnPrice"></i></div>
			</div>
			<div class="info-one flex">
				<div class="l">发票</div>
				<div class="r flex1 han_1">暂不支持开票</div>
			</div>
		</div>


		<!--底部按钮-->
		<div style="width: 100%;height: 80px;"></div>
		<div class="bot-btn">
            <div id="app-footer" class="flex" style="align-items: center;">
    			<div class="price flex1">应付金额:  <span>¥<i v-text="Pdata.orderPayPrice"></i></span></div>
    			<div class="btn" tapmode onclick="openPayMsg()">提交订单</div>
            </div>
		</div>

    </div>
<script type="text/javascript" src="../../script/base.min.js" id="loadjs" data-load=""></script>
<script type="text/javascript">
	var buyData = {};
    var selQuan = 0;
    lanYun.setFooter('app-footer');
	define(function (require, exports, module) {
	    pageParam = api.pageParam;
	    buyData = pageParam;

	    getData = function(loading) {
            //console.log(JSON.stringify(buyData));
	        lanYun.post('OrderPush/index', buyData ,function (ret) {
	            //console.log(JSON.stringify(ret));
                if(ret.errcode == 0){
                    lanYun.vue.Pdata = lanYun.copy(ret.data);
                    if(ret.data.orderQuanData){
                        selQuan = ret.data.orderQuanData.id;
                    }
                    if(ret.data.address){
                        buyData.address = ret.data.address;
                    }
                    lanYun.vue.price = ret.data.orderGoodsPrice;
                    lanYun.vue.$nextTick(function () {
    	                isApp && api.parseTapmode();
    	            });
                }else {
                    lanYun.alert({fname:'diaLogBox1',title:'提示', button:['确定'],content: ret.msg },function(ret){
                        api.closeWin();
                    });
                }
	        },loading);
	    };

	    lanYun.newVue('#vue',{
	        action:pageParam.action,
            price:0,
            Pdata:{orderQuanData:{}},
            shoptype:pageParam.shoptype || ''
	    },function() {
	        getData(2);
	    });

	    //============================

	    onShow = function () {
	        var address = lanYun.getStorage('address');
            var reshpage = lanYun.getStorage('reshpage');
            var quanData = lanYun.getStorage('quanData');
	        if(address){
	            lanYun.vue.Pdata.address = address;
                buyData.address = address;
	            lanYun.rmStorage('address');
                getData(2);
	        }
            if(quanData){
                buyData.quansel = quanData.id;
                lanYun.rmStorage('quanData');
                getData(2);
	        }
            if(reshpage){
                lanYun.rmStorage('reshpage');
                getData(2);
	        }
	    };

        // 输入长度
		inputMiaoShu = function (tis){
			var length = $(tis).val().length;
            if(length >= 100){
                lanYun.toast('留言过长');
            }
		}

		//打开地址选择
	    open_address = function () {
	        lanYun.openWin('user/address/sel_addr.html', {
	            title : '选择收货地址'
	        });
	    };

		//打开优惠券选择
	    open_quan = function () {
            var data = lanYun.vue.price;
            //console.log(JSON.stringify(selQuan));
	        lanYun.openWin('user/quan/sel_quan.html', {
	            title : '选择优惠券',
                border:'1',
                frameParam : {price:data,id:selQuan},
	        });
	    };

        // 关闭当前窗口
        closewin = function () {
            api.closeWin({name:api.winName});
        }

	    //下单
	    openPayMsg = function (sta) {
            if(lanYun.vue.Pdata.isNotbuy == 1){
                lanYun.toast(lanYun.vue.Pdata.isNotbuyMsg);
                return;
            }
            var beizhu = {};
            $('.beizhu').each(function(a,f) {
                var zid =  $(this).data('id');
                beizhu[zid] = $(this).val() || '';
            });
            buyData.beizhu = beizhu;
            buyData.quansel = lanYun.vue.Pdata.orderQuanData.id;
            buyData.address = lanYun.vue.Pdata.address;
            if(!buyData.address){
	            lanYun.toast('请选择收货地址');
	            return;
	        }
            //console.log(JSON.stringify(buyData));
            //return;
	        lanYun.post('OrderPush/addOrder', buyData ,function (ret) {
	            //console.log(JSON.stringify(ret));
	            if(ret.errcode==0) {
                    lanYun.openWin('goods/pay/pay_sel.html', {
        	            title : '选择支付方式',
                        border:'1',
                        frameParam :{id:ret.orderid,price:ret.orderPayPrice,endmiao:ret.endmiao,buytype:'buyshop',from:"ordert",endtype:ret.endtype,action:pageParam.action},
        	        });
                    lanYun.event('updatecart');
                    lanYun.event('uporderNum');
	            }else if(ret.errcode==1){
                    lanYun.alert({fname:'diaLogBox1',title:'提示', button:['确定'],content: ret.msg },function(ret){
                        api.closeWin();
        	        });
                }else if(ret.errcode==2){
                    lanYun.event('updatecart');
                    lanYun.event('uporderNum');
                    lanYun.openFrame('goods/pay/paymsg.html',{sta:1,ani:1,orderid:ret.data,price:"0.00",paytype:"dk"},function (data) {
    				});
                }
                else {
                    lanYun.toast(ret.msg);
                }
	        },2);
	    };

	});
</script>
</body>
</html>
